package com.answerz.module_reportissues.view

import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.databinding.BindingAdapter
import com.answerz.module_reportissues.R

/**
 *
 * @Description:
 * @Author: XCH
 * @CreateDate: 2021/12/9 13:59
 */
class EventDescriptionView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
    FrameLayout(context, attrs, defStyleAttr) {

    constructor(context: Context) : this(context, null, 0)
    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)

    var titleTv: TextView
        private set
    var contentTv: TextView
        private set

    init {
        inflate(getContext(), R.layout.view_event_description, this)
        titleTv = findViewById(R.id.tv_title)
        contentTv = findViewById(R.id.tv_content)

        if (attrs != null) {
            val styled =
                getContext().obtainStyledAttributes(attrs, R.styleable.EventDescriptionView)
            initAttributes(styled)
            styled.recycle()
        }
    }

    private fun initAttributes(styled: TypedArray) {
        var title = styled.getString(R.styleable.EventDescriptionView_ed_title)
        titleTv.text = title
        var content = styled.getString(R.styleable.EventDescriptionView_ed_content)
        contentTv.text = content
    }


}